function LibraryAdd_Code(id){
	var buffer = new StringBuffer();
	buffer.append('<div id="libraryid" val="'+id+'" class="crmsheet border-bottom"><div class="ctitle"><div class="cname">仓库编号</div><div class="require">*</div></div><div class="ctext"><input id="txt_num" type="text" placeholder="填写仓库编号" value=""/></div><div class="carrow"></div></div>');
	buffer.append('<div class="crmsheet border-bottom"><div class="ctitle"><div class="cname">仓库名称</div><div class="require">*</div></div><div class="ctext"><input id="txt_name" type="text" placeholder="填写仓库名称" value=""/></div><div class="carrow"></div></div>');
	buffer.append('<div class="crmsheet border-bottom"><div class="ctitle"><div class="cname">仓库地址</div></div><div class="ctext"><input id="txt_address" type="text" placeholder="填写仓库地址" value=""/></div><div class="carrow"></div></div>');
	buffer.append('<div class="crmsheet border-bottom"><div class="ctitle"><div class="cname">仓库管理员</div></div><div class="ctext"><input id="txt_manager" type="text" placeholder="填写仓库管理员" value="" onfocus="ScrollTop()"/></div><div class="carrow"></div></div>');
	buffer.append('<div class="crmsheet border-bottom"><div class="ctitle"><div class="cname">联系电话</div></div><div class="ctext"><input id="txt_mobile" type="text" placeholder="填写联系电话" value="" onfocus="ScrollTop()"/></div><div class="carrow"></div></div>');
	buffer.append('<div class="crmsheet border-bottom" style="height:120px;"><div class="ctitle"><div class="cname">备注</div></div><textarea id="txt_bak" placeholder="填写备注" onfocus="ScrollTop()"></textarea></div>');
	return buffer.toString();
};


function Init_LibraryAdd(){
    var data = {};
	data.act = "One_Library";
	data.id=$("#libraryid").attr("val");
	data.source=source;
	data.userid=userid;
	data.comid=comid;
	data.sign=GetSign(data.act);
	mui.getJSON(crm_domain, data, function (json) {
	    if (json.state) {
	    	var library=json.data;
	    	$("#txt_num").val(library.Num);
	    	$("#txt_name").val(library.Name);
	    	$("#txt_address").val(library.Address);
	    	$("#txt_manager").val(library.Manager);
	    	$("#txt_mobile").val(library.Mobile);
	    	$("#txt_bak").val(library.Bak);
	    }
	});

};




function Save_Library() {
        var data = {};
        var txt_num = $("#txt_num");
        var txt_name = $("#txt_name");
        data.id = $("#parentid").attr("val");
        if(txt_num.val().Trim()=="")
        {
        	plus.nativeUI.toast("请输入仓库编号");
        	return false;
        }
        if(txt_name.val().Trim()=="")
        {
        	plus.nativeUI.toast("请输入仓库名称");
        	return false;
        }
		data.act = "Save_Library";
		data.id=$("#libraryid").attr("val");
        data.parentid= $("#txt_parentid").val();
        data.num = txt_num.val();
        data.name = txt_name.val();
        data.address = $("#txt_address").val();
        data.manager = $("#txt_manager").val();
        data.mobile = $("#txt_mobile").val();
        data.bak = $("#txt_bak").val();
        data.userid=userid;
		data.comid=comid;
        data.source = source;
        data.version = version;
        data.sign=GetSign(data.act);
        mui.getJSON(crm_domain, data, function (json) {
            if (json.state) {
                CloseWindow();
                plus.nativeUI.toast(json.msg);
                if(data.id==0)
                {
                	Receive_Library(1);
                }else{
                	Init_LibraryDetail();
                	obj.find(".customername").html(data.name);
                	obj.find(".state").html("管理员："+data.manager.ToString());
                }
                
            } else {
				plus.nativeUI.toast(json.msg); 
            }
        });
};
